//
//  NRWCarPopTool.m
//  NRWMall
//
//  Created by 张记 on 2018/5/23.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWCarPopTool.h"
#import "zhPopupController.h"
#import "NRWCarInputNumView.h"
#import "NRWCarDetailModel.h"
@implementation NRWCarPopTool
+ (NRWCarDetailAlertView *)basePopupWithType:(PopUpViewType)type carModel:(CarResult *)result{
    
    return [[NRWCarDetailAlertView alloc] initWithType:type carModel:result];
}
+ (void)popUpWithController:(UIViewController *)controller type:(PopUpViewType)type carModel:(CarResult *)result  success:(void (^)(id info))success{

    NRWCarDetailAlertView *popView = [self basePopupWithType:type carModel:result];
    popView.frame = CGRectMake(0, 0, popView.frame.size.width, popView.frame.size.height);
    kSelfWeak;
    popView.basePopUpViewBlock = ^(id result) {
        success(result);
        [weakSelf dismissController:controller];
    };
    [self popBottomWithController:controller view:popView];

}

+ (void )popBottomWithController:(UIViewController *)controller view:(UIView *)view{
    
    controller.zh_popupController = [zhPopupController popupControllerWithMaskType:zhPopupMaskTypeBlackTranslucent];
    controller.zh_popupController.slideStyle = zhPopupSlideStyleShrinkInOut1;
    controller.zh_popupController.layoutType = zhPopupLayoutTypeCenter;
    [self popWithController:controller view:view];
}

+ (void)popWithController:(UIViewController *)controller view:(UIView *)view {
    
    controller.zh_popupController.maskTouched = ^(zhPopupController * _Nonnull popupController) {
        [popupController dismissWithDuration:0.25 springAnimated:NO];
    };
    
    [controller.zh_popupController presentContentView:view duration:0.75 springAnimated:YES];
}

+ (void)dismissController:(UIViewController *)controller {
    
    [controller.zh_popupController dismissWithDuration:0.25 springAnimated:NO];
}
@end
